robloxfandomcom_tr-20200213-history
Modül:Key
local kbdPrefix = '' local kbdSuffix = '' local keyText = { lock' = '⇪ Caps Lock', 'shift' = '⇧ Shift', 'enter' = '↵ Enter', 'cmd' = '⌘ Cmd', 'command' = '⌘ Command', 'opt' = '⌥ Opt', 'option' = '⌥ Option', 'tab' = 'Tab ↹', 'backspace' = '← Backspace', 'win' = '⊞ Win', 'menu' = '≣ Menu', 'up' = '↑', 'down' = '↓', 'left' = '←', 'right' = '→', 'asterisk' = '*', 'hash' = '#', 'colon' = ':', 'pipe' = '|', 'semicolon' = ';', 'equals' = '=', -- Left & right analog sticks. up' = 'L↑', down' = 'L↓', left' = 'L←', right' = 'L→', ne' = 'L↗', se' = 'L↘', nw' = 'L↖', sw' = 'L↙', up' = 'R↑', down' = 'R↓', left' = 'R←', right' = 'R→', ne' = 'R↗', se' = 'R↘', nw' = 'R↖', sw' = 'R↙', -- PlayStation. 'ex' = '×', 'circle' = '○', 'square' = '□', 'triangle' = '△', -- Nintendo 64 and GameCube. up' = 'C↑', down' = 'C↓', left' = 'C←', right' = 'C→', ne' = 'C↗', se' = 'C↘', nw' = 'C↖', sw' = 'C↙', } local keyAlias = { -- name for key (alias)' = 'name for key used in key table' ['cmd'] = 'cmd', ['command'] = 'command', ['opt'] = 'opt', ['option key'] = 'option', ['option'] = 'option', ['win'] = 'win', '*' = 'asterisk', '#' = 'hash', ':' = 'colon', ';' = 'semicolon', 'l-up' = 'l up', 'l-down' = 'l down', 'l-left' = 'l left', 'l-right' = 'l right', 'l-ne' = 'l ne', 'l-se' = 'l se', 'l-nw' = 'l nw', 'l-sw' = 'l sw', 'r-up' = 'r up', 'r-down' = 'r down', 'r-left' = 'r left', 'r-right' = 'r right', 'r-ne' = 'r ne', 'r-se' = 'r se', 'r-nw' = 'r nw', 'r-sw' = 'r sw', x' = 'ex', c' = 'circle', s' = 'square', t' = 'triangle', 'c-up' = 'c up', 'c-down' = 'c down', 'c-left' = 'c left', 'c-right' = 'c right', 'c-ne' = 'c ne', 'c-se' = 'c se', 'c-nw' = 'c nw', 'c-sw' = 'c sw', } local Collection = {} Collection.__index = Collection do function Collection:add(item) if item ~= nil then self.n = self.n + 1 selfself.n = item end end function Collection:join(sep) return table.concat(self, sep) end function Collection:sort(comp) table.sort(self, comp) end function Collection.new() return setmetatable({n = 0}, Collection) end end local function keyPress(args) local chainNames = { 'chain first', 'chain second', 'chain third', 'chain fourth', 'chain fifth', 'chain sixth', 'chain seventh', 'chain eighth', 'chain ninth', } local result = Collection.new() local chainDefault = args.chain or '+' for i, id in ipairs(args) do if i > 1 then result:add(args[chainNames- 1] or chainDefault) end local lc = id:lower() local text = keyTextlc or keyText[keyAliaslc] or id result:add(kbdPrefix .. text .. kbdSuffix) end return result:join() end local function keypress(frame) -- Called by " ". -- Using the template doubles the post‐expand include size. return keyPress(frame:getParent().args) end local function press(frame) -- Called by " ". return keyPress(frame.args) end return { keypress = keypress, press = press, }